package cn.itsource.ymjs.web.controller;

import cn.itsource.ymjs.dto.CourseDto;
import cn.itsource.ymjs.entify.FitnessCourse;
import cn.itsource.ymjs.query.CourseQuery;
import cn.itsource.ymjs.result.JSONResult;
import cn.itsource.ymjs.service.IFitnessCourseService;
import cn.itsource.ymjs.util.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

//@RefreshScope  //刷新配置
@RestController
@RequestMapping("/fitnessCourse")
@Api
public class FitnessCourseController  extends BaseController<FitnessCourse, CourseQuery>{

    @Autowired
    private IFitnessCourseService fitnessCourseService;

    @PostMapping("/save")
    @ApiOperation(value = "添加一个对象")
    public JSONResult add(@RequestBody CourseDto dto){
        FitnessCourse rt = fitnessCourseService.add(dto);
        return JSONResult.success(rt);
    }

    /**
     * 课程上线
     * @param ids
     * @return
     */
    @PostMapping("/online")
    @ApiOperation(value = "课程上线")
    public AjaxResult online(@RequestBody List<Long> ids) {
        return fitnessCourseService.online(ids);
    }

    /**
     * 课程下线
     * @param ids
     * @return
     */
    @PostMapping("/offline")
    @ApiOperation(value = "课程下线")
    public AjaxResult offline(@RequestBody List<Long> ids) {
        return fitnessCourseService.offline(ids);
    }

}
